﻿<div class="layui-card" id="lg-MCodeAdd">
    <div class="layui-card-header">
        <i class="fa fa-home fa-fw"></i>添加媒体码
        <div class="f-r">
            <button class="layui-btn layui-btn-primary layui-btn-sm" v-on:click="back()"><i class="fa fa-mail-reply fa-fw"></i>返回</button>
        </div>
    </div>
    <div class="layui-card-body" id="">
        <div class="layui-form-item">
            <form class="layui-form layui-form-pane" action="" id="fm_AddMCode" lay-filter="fm_AddMCode">
                <div class="layui-form-item">
                    <label class="layui-form-label"><i style="color:#f00">*</i>名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="Title" class="layui-input" placeholder="填写名称" lay-verify="required" />
                    </div>
                </div>
               <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">描述</label>
                    <div class="layui-input-block">
                        <textarea placeholder="填写描述" name="Intro" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><i style="color:#f00">*</i>目标地址</label>
                    <div class="layui-input-block">
                        <input type="text" name="LinkUrl" class="layui-input" placeholder="目标地址" lay-verify="required" />
                    </div>
                </div>
                <div class="layui-form-item" pane="">
                    <label class="layui-form-label">是否启用</label>
                    <div class="layui-input-block">
                        <input type="checkbox" checked="" name="IsUsing" value="1" lay-skin="switch" lay-filter="IsUsing" lay-text="ON|OFF">
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block text-center">
                        <button class="layui-btn" lay-submit lay-filter="bt_AddMCode">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
        <!-- 内容主体区域结束 -->
    </div>
</div>
<script>
    frame.createPage({
        mounted: function() {
            var page = this;
            page.vm = Vue.createApp({
                data() {
                    return {
                       
                    }
                },
                mounted: function() {
                    this.FormRander();
                },
                methods: {
                    back: function() {
                        frame.Back(page.url, res => {
                            res.reload()
                        })
                    },
                    FormRander: function() {
                        var that=this;
                        layui.use(['form', 'laydate'], function() {
                            var form = layui.form;
                            form.render();
                            form.on('submit(bt_AddMCode)', function(d) {
                                var data = d.field;
                                if (!data.IsUsing) {
                                    data.IsOpen = 0
                                }
                                lg.request({
                                    url: "/api/sys/media/AddMCode",
                                    method: "post",
                                    data: data,
                                    success: res => {
                                        if (res.code == 0) {
                                            layer.msg("添加成功！", { icon: 1 });
                                            that.back();
                                        } else {
                                            layer.msg(res.msg, { icon: 2 })
                                        }
                                    }
                                })
                                return false;
                            })
                        })
                    },
                }
            }).mount("#lg-MCodeAdd")
        },
    }).mount();
</script>